import { SubjectComponent } from "../../../../core/subject";
import World from "../../world";

const { ccclass, property } = cc._decorator;

@ccclass
export default class BulletSpawner extends SubjectComponent {
    @property
    tag = "";
    create(world: World) {
        if (!this.tag) {
            console.error(this.node.name + "spawn失败， 必须写入TAG");
            return null;
        }
        let bullet = world.findBulletByTag(this.tag);
        if (bullet) {
            console.warn(`BulletSpawner: Tag${this.tag}已经存在，不重复创建。`)
        }
        else {
            //todo: 2024-6-14
            this.emit("create", this);//this._createBullet(this.node.name, this.node.position, this.tag));
        }
        this.node.destroy();
    }
    //todo: 2024-6-14
    _createBullet(prefabName: string, pos: cc.Vec3 | cc.Vec2, tag: string) {
        // let netCom = NetBullet.CreateDynamic(prefabName);
        // netCom.bullet.node.setPosition(pos);
        // netCom.once("ready", () => {
        //     Sync.NextUpdate().then(() => {
        //         netCom.bullet.tag = tag;
        //     });
        // }, this)
        // return netCom;
    }
};